<?php
/**
 * Created by PhpStorm.
 * User: liuchaozhong
 * Date: 2017/8/30
 * Time: 下午8:04
 */

//sql调试
function getLastSql() {
    \Illuminate\Support\Facades\DB::listen(function ($sql) {
        foreach ($sql->bindings as $i => $binding) {
            if ($binding instanceof \DateTime) {
                $sql->bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
            } else {
                if (is_string($binding)) {
                    $sql->bindings[$i] = "'$binding'";
                }
            }
        }
        $query = str_replace(array('%', '?'), array('%%', '%s'), $sql->sql);
        $query = vsprintf($query, $sql->bindings);
        print_r($query);
        echo '<br/>';
    });
}

//用于转换urlxxx-xxx-xxx 成 xxx/xxx/xxx
if (!function_exists('menu2Tag')) {
    function menu2Tag($url)
    {
        $url_now = explode('-',$url);
        $url_now = implode('/',$url_now);
        return $url_now;
    }
}
